//
//  YQFoundVC.m
//  NewRetail
//
//  Created by yuqin on 2019/6/24.
//  Copyright © 2019 yuqin. All rights reserved.
//

#import "YQFoundVC.h"
#import "YQHeadView.h"
#import "YQInformationCell.h"
#import "YQIncubatorVC.h"

@interface YQFoundVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *foundTableView;
@property (nonatomic ,strong) YQHeadView *foundHeadView;

@end

@implementation YQFoundVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.view.backgroundColor = UIColorFromRGB(0xeeeeee);
    [self.headView setHidden:YES];
    self.txtTitle.text = @"发现";
    [self setupFoundView];
    
}

- (void)setupFoundView {
    [self.view addSubview:self.foundHeadView];
    [self.foundHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, FIT(330)));
    }];
    
    UIView *backView = [[UIView alloc] init];
    backView.backgroundColor = UIColorFromRGB(0xeeeeee);
    [self.view addSubview:backView];
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.equalTo(self.foundHeadView.mas_bottom).mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, FIT(10)));
    }];
    
    //标题
    UILabel *theTitleLab = [YQViewFactory labelWithTextColor:MainBlackColor textAlignment:NSTextAlignmentLeft fontSize:kTheTitleFont userBold:NO];
    theTitleLab.text = @"资讯";
    [self.view addSubview:theTitleLab];
    [theTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.equalTo(backView.mas_bottom).mas_equalTo(FIT(0));
        make.size.mas_equalTo(CGSizeMake(FIT(100), FIT(40)));
    }];
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = LineColor;
    [self.view addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.equalTo(theTitleLab.mas_bottom).mas_equalTo(1);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, 1));
    }];
    
    [self.view addSubview:self.foundTableView];
    [self.foundTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineView.mas_bottom).mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, ScreenHeight-FIT(380)));
    }];
}

- (YQHeadView *)foundHeadView {
    if (!_foundHeadView) {
        _foundHeadView = [[YQHeadView alloc] init];
        @weakify(self);
        _foundHeadView.block = ^(NSInteger tag) {
            @strongify(self);
            YQ_PUSH([YQIncubatorVC new]);
        };
    }
    return _foundHeadView;
}

- (UITableView *)foundTableView {
    if (!_foundTableView) {
        _foundTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _foundTableView.delegate = self;
        _foundTableView.dataSource = self;
        [_foundTableView  setSeparatorStyle:UITableViewCellSeparatorStyleNone];
        [_foundTableView registerNib:[UINib nibWithNibName:YQ_InformationCell bundle:nil] forCellReuseIdentifier:YQ_InformationCell];
    }
    return _foundTableView;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return FIT(92);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YQInformationCell *cell = [tableView dequeueReusableCellWithIdentifier:YQ_InformationCell forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

@end
